import subprocess
import threading
def ping(host):
    retval = subprocess.run(
        'ping -c1 %s &> /dev/null' % host,
        shell = True
    )
    if retval.returncode == 0:
        print('%s:up' % host)
    else:
        print('%s:down' % host)

if __name__ == '__main__':
    ips = ('192.168.4.%s' % i for i in range(1,255))
    for ip in ips:
        t = threading.Thread(target=ping,args=(ip,))
        t.start()
